package iterator.impl;

import iterator.MyIterator;
import list.impl.MyArrayList;

public class MyArrayListIterator<T> implements MyIterator<T> {

    private int current;

    private MyArrayList list;

    public MyArrayListIterator(MyArrayList list) {
        this.current = 0;
        this.list = list;
    }

    @Override
    public T next() {
        if (current < list.size()) {
            return (T) list.get(current++);
        }
        return null;
    }

    @Override
    public boolean hasNext() {
        return current < list.size();
    }
}
